[master] Contact No. Lookup on Sales Quote returns All Customers instead of related Contacts after Updating to v28.2 - regression.#9374
Conversation
Copilot PR ReviewIteration 3 · Outcome: completed
Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
Agentic PR Review - Round 1Recommendation: Request ChangesWhat this PR doesThis PR removes the Quote exclusion in The code fix matches the root cause. The Sales Quote SuggestionsS1 - Test the Contact No. lookup The new test calls Risk assessment and necessityRisk: The runtime change is narrow, but it affects all existing Sales Header layer copies. The main risk is test confidence: the added test exercises the Contact name lookup path, not the changed Contact No. lookup path. There is no public API or event signature change. Necessity: The linked work item is a Bug and describes a real v28.2 regression. Without this fix, Sales Quote users can see unrelated contacts and choose the wrong contact for the selected customer. The code scope is right, but the regression test must cover the actual lookup that regressed.
|
…Bug-642199-Contact-No.-Lookup-on-Sales-Quote-returns-All-Customers
|
@alexei-dobriansky Suggested fix done. |
SelltoContactLookup (SalesHeader.Table.al) was changed to always filter the contact list by the customer's Company No., removing the prior '("Document Type" <> "Document Type"::Quote)' exemption — this is the intended fix for bug 642199 and is well covered by the new test.However, the sibling OnValidate trigger for the same field still contains that exemption a few hundred lines earlier: '("Sell-to Customer No." <> '') and ("Sell-to Contact No." <> '') and ("Document Type" <> "Document Type"::Quote)' guarding the call to CheckContactRelatedToCustomerCompany. After this change, a user can no longer pick an off-company contact via the lookup on a Quote, but can still type/paste one directly into the field on a Quote without triggering the company-relation error that Orders/Invoices/Credit Memos get on the same field. The lookup and validation are now inconsistent specifically for Quotes, which is exactly the scenario this PR targets. If the intent is that Quotes should also enforce company-matching (consistent with the new lookup behavior and with Bill-to Contact No., which validates the company relation unconditionally for all document types), the same '<> "Document Type"::Quote' exemption on the Validate trigger should be reconsidered/removed as part of this fix; if it is intentionally left permissive for manual entry, that asymmetry deserves a code comment so it isn't mistaken for a leftover of the bug being fixed. Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Agentic PR Review - Round 2Recommendation: AcceptWhat this PR doesThe new commit updates the regression test from round 1. The test now uses This addresses the previous concern. The Sales Quote Status of previous suggestions
New observations (commits since round 1)None - changes only addressed prior suggestions. Risk assessment and necessityRisk: The round-2 commit only changes the test, so it adds no runtime regression surface. The test now exercises the same Sales Quote Necessity: The linked work item is a Bug for a v28.2 regression where Sales Quote
|
There was a problem hiding this comment.
Pull request overview
Fixes a regression in v28.2 where Sales Quote “Sell-to Contact No.” lookup stopped filtering to the selected customer’s related contacts, causing the lookup to show all contacts instead.
Changes:
- Removed the
"Document Type" <> Quoteexclusion inSelltoContactLookup()so Sales Quotes apply the same customer-based contact filtering as other sales documents. - Applied the same fix across multiple localized BaseApp layers (W1 + country layers).
- Added a targeted test covering Sales Quote contact lookup filtering for a customer scenario.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Layers/W1/Tests/Marketing/TestContactLookup.Codeunit.al | Adds a regression test for Sales Quote “Sell-to Contact No.” lookup filtering. |
| src/Layers/W1/BaseApp/Sales/Document/SalesHeader.Table.al | Fixes SelltoContactLookup() by removing Quote exclusion from customer-based filtering. |
| src/Layers/SE/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for SE layer. |
| src/Layers/RU/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for RU layer. |
| src/Layers/NO/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for NO layer. |
| src/Layers/NL/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for NL layer. |
| src/Layers/NA/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for NA layer. |
| src/Layers/IT/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for IT layer. |
| src/Layers/GB/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for GB layer. |
| src/Layers/FR/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for FR layer. |
| src/Layers/FI/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for FI layer. |
| src/Layers/ES/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for ES layer. |
| src/Layers/CZ/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for CZ layer. |
| src/Layers/CH/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for CH layer. |
| src/Layers/BE/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for BE layer. |
| src/Layers/APAC/BaseApp/Sales/Document/SalesHeader.Table.al | Same fix as W1 for APAC layer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
qasimikram
left a comment
There was a problem hiding this comment.
The production fix is focused and consistently applied across all layers, and the regression test covers the quote-specific filtering scenario.
S1: Please add [Scope('OnPrem')] to SellToContactLookupOnSalesQuoteWithCustomerTest. It references ContactListModalPageHandler, which is scoped OnPrem, and the existing tests that use this handler carry the same scope.
Workitem: Bug 642199: [master] [ALL-E] Contact No. Lookup on Sales Quote returns All Customers instead of related Contacts after Updating to v28.2 - regression.
Fixes AB#642199
Issue: On a Sales Quote, the Contact No. field lookup showed all contacts (customers and vendors) instead of only the selected customer's contacts (regression in v28.2; other documents worked fine).
Cause: In SelltoContactLookup() the filter condition included ("Document Type" <> "Document Type"::Quote), which skipped the contact-relation filtering entirely for quote documents.
Solution: Removed the Quote exclusion so quotes apply the same customer-based contact filter as other documents, while the "Sell-to Customer No." <> '' guard preserves the quote-for-a-prospect flow.